package demo.standard;

public class ConcreteIterator implements IIterator {

    private IAggregate aggregate;

    private Object[] arr;
    private int cursor = -1;

    public ConcreteIterator(IAggregate aggregate, Object[] arr) {
        this.aggregate = aggregate;
        this.arr = arr;
    }

    @Override
    public Object getFirst() {
        return arr[0];
    }

    @Override
    public boolean hasNext() {
        return (arr.length - 1) > cursor;
    }

    @Override
    public Object getNext() {
        return arr[++cursor];
    }

    @Override
    public Object getCurrent() {
        if (cursor < 0) {
            return null;
        }
        return arr[cursor];
    }
}
